﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using KKSGameLibrary.Logic;

namespace KaKaSongGame
{
    public partial class CardSetView : UserControl
    {
        public CardSetView()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(CardSetView_Loaded);
        }

        void CardSetView_Loaded(object sender, RoutedEventArgs e)
        {
            InitView();
        }

        public CardInMap CurrentCard
        {
            get;
            set;
        }

        public void Next()
        {
            clockwiseSB.Stop();
            anticlockwiseSB.Stop();

            //CurrentCard = _cards.GetCard();
            ShowCard();
        }

        void ShowCard()
        {
            var view = _presenter.CreateCardView(CurrentCard);
            cardcontainer2.Children.Clear();
            cardcontainer2.Children.Add(view);
        }

        CardSet _cards;
        ICardPresenter _presenter;
        public void InitView()
        {
            _presenter = new CardPresenter();
            _cards = new CardSet();
            Next();
        }


        private void Clockwise_rotate(object sender, RoutedEventArgs e)
        {
            CurrentCard.Rotation = (RotationDegree)(((int)CurrentCard.Rotation + 1) % 4);
            clockwiseSB.Begin();
        }

        private void AntiClockwise_rotate(object sender, RoutedEventArgs e)
        {
            CurrentCard.Rotation = (RotationDegree)(((int)CurrentCard.Rotation + 3) % 4);
            anticlockwiseSB.Begin();
        }

        private void panelDragDropTarget1_GiveFeedback(object sender, Microsoft.Windows.GiveFeedbackEventArgs e)
        {
            var cc = e.Effects;
            if (cc != Microsoft.Windows.DragDropEffects.Move)
            {
            }
        }

        private void panelDragDropTarget1_Drop(object sender, Microsoft.Windows.DragEventArgs e)
        {

        }

        private void panelDragDropTarget1_ItemDragCompleted(object sender, ItemDragEventArgs e)
        {

        }

        private void panelDragDropTarget1_ItemDroppedOnSource(object sender, Microsoft.Windows.DragEventArgs e)
        {

        }

        private void panelDragDropTarget1_ItemDroppedOnTarget(object sender, ItemDragEventArgs e)
        {
            e.Effects = Microsoft.Windows.DragDropEffects.Copy;
            
        }

        private void panelDragDropTarget1_ItemDragStarting(object sender, ItemDragEventArgs e)
        {
            
            e.AllowedEffects = Microsoft.Windows.DragDropEffects.Copy;
            e.Data = CurrentCard;
            //e.Effects = Microsoft.Windows.DragDropEffects.Copy;
        }
    }
}
